


public class MyQueue<T> {
    private static class Node<T> {
        T value;
        Node<T> next;

        Node(T value) {
            this.value = value;
        }
    }

    private Node<T> head;    //出队端
    private Node<T> tail;    //入队端

    public MyQueue() {
        head = null;
        tail = null;
    }

    /*
    *
先3月试用期最后提涨薪 1跳看业务  2跳看待遇

1w 1.3(待年) 1.5-1.8(3年)
*
* */

    //入队操作
    public void enqueue(T value) {
        Node<T> newNode = new Node<>(value);
        if (tail != null) {
            tail.next = newNode;
        }
        tail = newNode;
        if (head == null) {
            head = tail;
        }
    }

    //出队
    public T dequeue() {
        if (head == null) {
            throw new RuntimeException("队列是空的");
        }
        T val = head.value;
        head = head.next;
        if (head == null) {
            tail = null;
        }
        return val;
    }

    //判断队列是否为空
    public boolean isEmpty() {
        return head == null;
    }

    @Override
    public String toString() {
        return super.toString();
    }
}
